<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>WDShare线下活动-西安前端交流会</title>
<meta name="keywords" content="WDShare线下活动,前端交流会" />
<meta name="description" content="WDShare线下活动,前端交流会" />
<% include ../etc/htmlhead.ejs %>
</head>

<body>
<% include ../etc/head.ejs %>
<%
  var showPageSize = 5;
      item_sum = +pages.sum,
      page_current = +pages.page,
      page_size = pages.pagesize,
      page_sum = Math.ceil(item_sum/page_size),
      pathname = pages.pathname,
      beforeOmit = false,
      afterOmit = false;


  function getPageHTML(c) {
    var _html = '';
    if ( i+1 == +page_current ) {
      _html += '<span class="pages-current">'+ c +'</span>';
    } else {
      _html += '<a href="'+ pathname +'?page='+ c +'&pagesize='+ page_size +'">'+ c +'</a>';
    }
    return _html;
  };
%>

<div class="activity activity-list">
  <div class="maxWidth module">
    <h2 class="module-title"><%= title %></h2>
    <div class="activity-con">
      <% result.forEach(function(active){ %>
      <a href="/active/<%= active._id %>" class="activity-item">
        <h3 class="activity-title"><em><%= active.aName %></em></h3>
        <div class="activity-type">
          <span class="activity-date">时间：<%= active.aTime %></span>
          <span class="activity-click">点击：<%= active.aClick ? active.aClick : 0 %></span>
          <!-- <span class="activity-comment">评论：15</span> -->
        </div>
        <% if ( active.aStatus == 1 ) { %>
        <div class="activity-state"><span class="open">报名</span></div>
        <% } else if ( active.aStatus == 2 ) { %>
        <div class="activity-state"><span class="stop">暂停</span></div>
        <% } else if ( active.aStatus == 3 ) { %>
        <div class="activity-state"><span class="ready">等待</span></div>
        <% } else { %>
        <div class="activity-state"><span class="over">详情</span></div>
        <% } %>
      </a>
      <% }) %>
    </div>
    <% if ( page_sum > 1 ) { %>
    <div class="pages">
      <div class="pages-con">
        <% if ( page_current != 1 ) { %>
        <a href="<%=pathname%>?page=<%=+page_current-1%>&pagesize=<%=page_size%>" class="pages-prev">上一页</a>
        <% } else { %>
        <span class="pages-prev pages-dead">上一页</span>
        <% } %>
        <% for( var i=0; i<page_sum; i++ ) { %>
          
          <% if ( i == 0 || i == page_sum-1 ) { %>
            <%- getPageHTML(i+1) %>
            <% continue %>
          <% } %>

          <% if ( page_current-Math.floor(showPageSize/2) > 2 && !beforeOmit ) { %>
            <span class="pages-omit">...</span>
            <% beforeOmit = true %>
          <% } %>

          <% if ( i+1 > page_current+Math.floor(showPageSize/2) ) { %>
            <% if ( !afterOmit ) { %>
              <span class="pages-omit">...</span>
              <% afterOmit = true %>
            <% } %>
            <% continue %>
          <% } %>

          <% if ( i+1 >= page_current-Math.floor(showPageSize/2) ) { %>
            <%- getPageHTML(i+1) %>
            <% continue %>
          <% } %>

        <% } %>
        <!-- <span class="pages-omit">...</span> -->
        <% if ( page_current >= page_sum ) { %>
        <span class="pages-next pages-dead">下一页</span>
        <% } else { %>
        <a href="<%=pathname%>?page=<%=+page_current+1%>&pagesize=<%=page_size%>" class="pages-next">下一页</a>
        <% } %>
      </div>
    </div>
    <% } %>
  </div>
</div>

<% include ../etc/foot.ejs %>
</body>
</html>